Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
20 lines (15 loc) · 368 Bytes

1.7.9 - 1.7.16 使用迭代器遍历Server所有连接.md

File metadata and controls

20 lines (15 loc) · 368 Bytes

1.7.16 使用迭代器遍历Server所有连接

swoole-1.7.16版本增加了客户端连接迭代器接口,可以非常轻松实现遍历当前服务器的所有连接。

遍历连接并广播

foreach($server->connections as $fd)
{
    $server->send($fd, "hello world\n");
}

获取连接总数

echo count($server->connections);